<template>
	<view :class="dataset.alias">
		<view class="form_split_10" v-if="!no_top_border"></view>
		<image v-if="dataset.items.length == 1" :src="dataset.items[0].image_src"
			@click="handlerClick(dataset.items[0])"></image>
		<swiper v-else :circular="true" :autoplay="true" @click-slide="handleClickSlide">
			<swiper-item v-for="(item, index) in dataset.items" :key="index">
				<image :src="item.image_src" mode="widthFix"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		name: 'Ad',
		props: ['dataset', 'no_top_border'],
		data() {
			return {}
		},
		methods: {
			handleClickSlide(index, reallyIndex) {
				this.handlerClick(this.dataset.items[reallyIndex])
			},
			handlerClick(item) {
				if (item.link_url) {
					window.location.href = item.link_url
				} else if (item.company_id > 0) {
					uni.navigateTo({
						url: '/company/' + item.company_id
					})
				} else if (item.inner_link) {
					let path = ''
					let params_type = 'query'
					switch (item.inner_link) {
						case 'index':
							path = '/'
							break
						case 'joblist':
							path = '/joblist'
							break
						case 'jobshow':
							path = '/job'
							params_type = 'params'
							break
						case 'resumelist':
							path = '/resumelist'
							break
						case 'noticeshow':
							path = '/notice'
							params_type = 'params'
							break
						case 'articlelist':
							path = '/newslist'
							break
						case 'articleshow':
							path = '/news'
							params_type = 'params'
							break
						default:
							path = ''
							break
					}
					if (path != '') {
						if (item.inner_link_params > 0) {
							if (params_type == 'query') {
								path = path + '?id=' + item.inner_link_params
							} else {
								path = path + '/' + item.inner_link_params
							}
						}
						uni.navigateTo({
							url: path
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.QS_index_banner_a,
	.QS_index_banner_b {
		.swiper-item {
			height: 130rpx;
		}

		image {
			width: 100%;
			height: 130rpx;
			border: 0;
		}

		height: 140rpx;
	}

	.QS_member_company_banner,
	.QS_member_personal_banner {
		.swiper-item {
			height: 155rpx;
		}

		image {
			width: 100%;
			height: 155rpx;
			border: 0;
		}

		height: 165rpx;
	}

	.QS_top_slide {
		.swiper-item {
			height: 240rpx;
		}

		image {
			width: 100%;
			height: 240rpx;
			border: 0;
		}

		height: 250rpx;
		position: relative;
	}
</style>
